package com.compoundsystem.user.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.compoundsystem.admin.result.Result;
import com.compoundsystem.compound.pojo.Compound;
import com.compoundsystem.dto.UserQueryDto;
import com.compoundsystem.mapper.UserMapper;
import com.compoundsystem.user.pojo.User;
import com.compoundsystem.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    UserService userService;


    @PostMapping ("/api/user/list")
    public Result userList(@RequestBody UserQueryDto userQueryDto)
    {
          return new Result(200,"",userService.selectUserPage(userQueryDto));

    }

    @PostMapping("/api/user/add")
    public Result addUser(@RequestBody User user){
        return new Result(200,"",userService.addUser(user));
    }


    @PostMapping("/api/user/update")
    public Result updateUser(@RequestBody User user){
        return new Result(200,"",userService.updateUser(user));
    }


    @PostMapping("/api/user/delete")
    public Result deleteUser(Integer id){
        return new Result(200,"",userService.deleteUser(id));
    }


    @PostMapping("/api/user/delete/batch")
    public Result batchDeleteUser(@RequestBody List<Integer> ids){
        userService.batchDelete(ids);
        return new Result(200,"","");
    }

}
